<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <script>
    // 只要未登录就跳转到登录页，已登录则停留首页
    if (!sessionStorage.getItem('isLoggedIn')) {
      window.location.href = 'login.html';
    }
  </script>
  <meta charset="UTF-8">
  <title>食物食材食品基本信息Web系统</title>
  <link rel="stylesheet" href="css/style.css">
</head>
<body>
  <div class="bg"></div>
  <div class="bg bg2"></div>
  <div class="bg bg3"></div>
  <header>
    <h1>食物食材食品基本信息Web系统</h1>
    <nav>
      <div class="user-menu" id="userMenu">
        <img src="img/avatar.png" alt="头像" class="avatar" id="userAvatar">
        <span class="username" id="usernameDisplay">用户</span>
        <span class="dropdown-arrow">&#9662;</span>
        <div class="dropdown-menu" id="dropdownMenu">
          <a href="#" id="profileLink"><span class="menu-icon">&#8962;</span> 个人空间</a>
          <a href="login.html" id="logout"><span class="menu-icon">&#9906;</span> 退出登录</a>
        </div>
      </div>
    </nav>
  </header>
  <main>
    <section>
      <div class="intro-card">
        <h2 style="color: #388e3c; font-family: '云峰字库重庆山城棒棒体', cursive, sans-serif; font-weight: bold;">欢迎使用食物食材食品基本信息系统</h2>
        <p>本系统致力于建立基于群体智慧的食物、食材、食品信息数据库。</p>
      </div>
    </section>
    <section>
      <h2>功能导航</h2>
      <div class="feature-grid">
        <div class="feature-card guest-only">
          <h3>数据查询</h3>
          <p>查询食物、食材、食品的基本信息</p>
          <a href="search.html" class="btn">进入查询</a>
        </div>
        <div class="feature-card user-only">
          <h3>数据录入</h3>
          <p>添加新的食物、食材、食品信息</p>
          <a href="add_food.html" class="btn">添加食物</a>
          <a href="add_ingredient.html" class="btn">添加食材</a>
          <a href="add_product.html" class="btn">添加食品</a>
        </div>
        <div class="feature-card admin-only">
          <h3>系统管理</h3>
          <p>表格管理、用户授权、数据备份</p>
          <a href="table_manage.html" class="btn">表格管理</a>
          <a href="auth_manage.html" class="btn">用户管理</a>
        </div>
        <div class="feature-card user-only">
          <h3>数据导入</h3>
          <p>批量导入食物、食材、食品信息（Excel）</p>
          <button class="btn" id="openImportModalBtn" onclick="window.location.href='import.html'">导入数据</button>
        </div>
        <div class="feature-card user-only">
          <h3>批量导出</h3>
          <p>导出所有数据为Excel文件</p>
          <a href="export.html" class="btn">导出数据</a>
        </div>
        <div class="feature-card user-only">
          <h3>建议反馈</h3>
          <p>对系统功能和数据结构提出建议</p>
          <a href="suggestion.html" class="btn">提交建议</a>
        </div>
        <div class="feature-card guest-only">
          <h3>操作帮助</h3>
          <p>系统使用指南和常见问题解答</p>
          <a href="help.html" class="btn">查看帮助</a>
        </div>
        <div class="feature-card admin-only">
          <h3>API文档</h3>
          <p>系统API接口详细说明</p>
          <a href="api_docs.html" class="btn">查看文档</a>
        </div>
      </div>
    </section>
  </main>
  <footer>
    <p>&copy; 2025 食物食材食品基本信息Web系统</p>
  </footer>
  <script src="js/user_menu.js"></script>
  <script src="js/role_control.js"></script>
</body>
</html> 